#include<iostream>
#include<cstring>
using namespace std;
class account {
private:
	double blance;
	char type;
	char number[10];
	double interest;
public:
	account();
	account(char* n, char t, double b);
	void add();
	void fint();
	account(const account& A);
	~account();
};
account::account(char* n, char t, double b) {
	for (int i = 0; i < strlen(n); i++) {
		number[i] = n[i];
	}
	number[strlen(n)] = 0;
	type = t;
	blance = b;
	interest = 0.005;
}
void account::add() {
	blance += blance * interest;
	cout << "Account=" << number << "--sum=" << blance << endl;
}
void account::fint() {
	cout << "Account=" << number << "--";
	if (type == 'P') {
		cout << "Person";
	}
	else {
		cout << "Enterprise";
	}
	cout << "--sum=" << blance << "--rate=" << interest << endl;
}
account::account(const account& A) {
	if (A.number[0] >= '5') {
		number[0] = '1';
		number[1] = A.number[0] - 5;
		for (int i = 1; i < strlen(A.number); i++) {
			number[i + 1] = A.number[i];
		}
		number[strlen(A.number) + 1] = 0;
	}
	else {
		number[0] = A.number[0] + 5;
		for (int i = 1; i < strlen(A.number); i++) {
			number[i] = A.number[i];
		}
		number[strlen(A.number)] = 0;
	}
	blance = A.blance;
	interest = 0.015;
	type = A.type;
}
account::~account() {
	blance = 0;
	type = 'P';
	for (int i = 0; i < 9; i++) {
		number[i] = 0;
	}
	interest = 0.005;
}
int main()
{
	int t;
	cin >> t;
	for (int i = 0; i < t; i++) {
		char number[9];
		char t;
		double blance;
		cin >> number >> t >> blance;
		account A(number, t, blance);
		account B(A);
		char a, b;
		cin >> a >> b;
		if (a == 'C') {
			A.add();
		}
		else {
			A.fint();
		}
		if (b == 'C') {
			B.add();
		}
		else{
			B.fint();
		}
	}
	return 0;
}